<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册页面</title>
    <style>
        body {
            font-family: "Microsoft YaHei", Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background: linear-gradient(120deg, #2980b9, #8e44ad);
            color: #333;
        }
        .register-container {
            background: rgba(255, 255, 255, 0.95);
            padding: 30px 40px;
            border-radius: 15px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
            width: 300px;
            backdrop-filter: blur(10px);
        }
        .register-container h2 {
            text-align: center;
            margin-bottom: 20px;
            color: #2c3e50;
            font-size: 28px;
            font-weight: 600;
        }
        .register-container input {
            width: 80%;
            padding: 12px 15px;
            margin: 15px 0;
            border: 2px solid #e3e3e3;
            border-radius: 8px;
            font-size: 16px;
            transition: all 0.3s ease;
            display: block;
            margin-left: auto;
            margin-right: auto;
        }
        .register-container input:focus {
            border-color: #3498db;
            outline: none;
            box-shadow: 0 0 8px rgba(52, 152, 219, 0.3);
        }
        .register-container button {
            width: 80%;
            padding: 12px;
            background: linear-gradient(to right, #3498db, #2980b9);
            border: none;
            color: white;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            margin-top: 10px;
            display: block;
            margin-left: auto;
            margin-right: auto;
            transition: all 0.3s ease;
        }
        .register-container button:hover {
            background: linear-gradient(to right, #2980b9, #3498db);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
        }
        .link {
            text-align: center;
            margin-top: 20px;
        }
        .link a {
            color: #3498db;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
        }
        .link a:hover {
            color: #2980b9;
        }
        @keyframes slideDown {
            from {
                transform: translate(-50%, -100%);
                opacity: 0;
            }
            to {
                transform: translate(-50%, 0);
                opacity: 1;
            }
        }
    </style>
</head>
<body>
    <div class="register-container">
        <h2>用户注册</h2>
        <form id="registerForm">
            <input type="text" id="username" placeholder="请输入用户名" required>
            <input type="password" id="password" placeholder="请输入密码" required>
            <input type="password" id="confirmPassword" placeholder="请确认密码" required>
            <button type="submit">立即注册</button>
        </form>
        <div class="link">
            <p>已有账号？ <a href="/">立即登录</a></p>
        </div>
    </div>

    <script>
        const registerForm = document.getElementById("registerForm");

        registerForm.onsubmit = function(event) {
            event.preventDefault();

            const username = document.getElementById("username").value;
            const password = document.getElementById("password").value;
            const confirmPassword = document.getElementById("confirmPassword").value;

            if (password !== confirmPassword) {
                showAlert("两次输入的密码不一致！");
                return;
            }

            // 这里可以添加更多的验证逻辑
            if (username.length < 3) {
                showAlert("用户名长度不能小于3个字符！");
                return;
            }

            if (password.length < 6) {
                showAlert("密码长度不能小于6个字符！");
                return;
            }

            // 模拟注册成功
            showAlert("注册成功！即将跳转到登录页面...", "success");
            setTimeout(() => {
                window.location.href = "/";
            }, 2000);
        }

        function showAlert(message, type = "error") {
            const alertDiv = document.createElement('div');
            alertDiv.style.cssText = `
                position: fixed;
                top: 20px;
                left: 50%;
                transform: translateX(-50%);
                background-color: ${type === "error" ? "#ff4444" : "#4CAF50"};
                color: white;
                padding: 15px 30px;
                border-radius: 5px;
                box-shadow: 0 2px 10px rgba(0,0,0,0.1);
                animation: slideDown 0.5s ease-out;
            `;
            alertDiv.textContent = message;
            document.body.appendChild(alertDiv);

            setTimeout(() => {
                alertDiv.remove();
            }, 3000);
        }
    </script>
</body>
</html>
